{# 
Template coming from
https://github.com/koxudaxi/datamodel-code-generator/blob/master/datamodel_code_generator/model/template/pydantic/BaseModel_root.jinja2.
We override it to inject `__iter__` and `__getitem__`, as per
https://pydantic-docs.helpmanual.io/usage/models/#custom-root-types

**NOTE: We also disable validation**
#}
{% for decorator in decorators -%}
{{ decorator }}
{% endfor -%}
class {{ class_name }}({{ base_class }}):
{%- if config %}
{% include 'Config.jinja2' %}
{%- endif %}
{%- if not fields %}
    pass
{%- else %}
    {%- if fields[0].field %}
    __root__: {{ fields[0].type_hint }} = {{ fields[0].field }}
    {%- elif fields[0].required or (fields[0].default == 'None' and fields[0].strip_default_none) %}
    __root__: {{ fields[0].type_hint }}
    {%- else %}
    __root__: {{ fields[0].type_hint }} = {{ fields[0].represented_default }}
    {%- endif %}

    def __iter__(self):
        return iter(self.__root__)

    def __getitem__(self, idx):
        return self.__root__[idx]

    def __len__(self):
        return len(self.__root__)
{%- endif %}
